<template>
  <div class="account">
    <div v-if="username">
      你好，{{username}}
      <nuxt-link to="/exit">[ 退出 ]</nuxt-link>
    </div>
    <div v-else>
      <nuxt-link to="/login">立即登录</nuxt-link> 
      <nuxt-link to="/regist">注册</nuxt-link>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState({
      username: state => state.user.username
    })
  }
};
</script>

<style lang="scss" scoped>
.account {
  text-align: right;
  height: 40px;
  line-height: 40px;
  background: #ddd;
  padding: 0 20px;
}
</style>